/**
 * 
 */
package com.acme.bankapp.domain.bank;

/**
 * @author Labun Konstantin
 * 
 */
public abstract class AbstractAccount implements Account {

    protected double balance;

    protected AbstractAccount(double startBalance) {
	super();
	balance = startBalance;
    }

    @Override
    public void deposit(double x) {
	balance += x;
    }

    /**
     * @return the balance
     */
    @Override
    public double getBalance() {
	return balance;
    }

    @Override
    public double maximumAmountToWithdraw() {
	return balance;
    }

    @Override
    public String toString() {
	return "Account's balance = " + getBalance();
    }

    @Override
    public void withdraw(double x) {
	assert (maximumAmountToWithdraw() >= x);
	if (balance >= x) {
	    balance -= x;
	}
    }
}
